import Vue from 'vue'
import App from './App.vue'

import 'element-ui/lib/theme-chalk/index.css';
import ElementUI from 'element-ui'

Vue.use(ElementUI);

import URL from './URL'

Vue.prototype.$URL = URL;

import UTIL from 'o_util_js'

Vue.prototype.UTIL = UTIL;
Vue.prototype.listPid = function listPid(arr, pid = 0, sep = "", sep2 = "", name) {
    let to = [];
    for (let a of arr) {
        if (a.pid === pid) {
            let c = this.listPid(arr, a.id, sep + sep2);
            if (c && c.length > 0) {
                a.children = c;
            }
            a[name] = sep + a[name];
            to.push(a);
        }
    }
    return to;
};
Vue.prototype.listOption = function listPid(arr, pid = 0, name, sep = "", sep2 = "") {
    let to = [];
    for (let a of arr) {
        if (a.pid === pid) {
            console.log(name);
            if (name) {
                a[name] = sep + a[name];
            } else {
                a["name"] = sep + a["name"];
            }
            to.push(a);
            let c = this.listOption(arr, a.id, name, sep + sep2);
            if (c && c.length > 0) {
                to = to.concat(c)
            }
        }
    }
    return to;
};


import MOMENT from "moment";

Vue.prototype.$moment = MOMENT;

import Cookie from 'js-cookie'

Vue.prototype.Cookie = Cookie;

import localForage from "localforage"

Vue.prototype.localForage = localForage;

import AJAXUtil from "./util/AJAXUtil";

Vue.prototype.$ajax = AJAXUtil;
Vue.config.productionTip = false;

Vue.prototype.$baseURL = process.env.VUE_APP_BASE_API;
Vue.prototype.$Title = process.env.VUE_APP_TITLE;
import router from './router'

new Vue({
    router,
    render: h => h(App),
}).$mount('#app');
